﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace PeisongWeb.admin
{
    public partial class passwordHistory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptBind();
            }

        }
        private void rptBind()
        {
            StringBuilder where = new StringBuilder();
            where.Append("1=1");
            if(txt_username.Text.Trim()!="")
                where.AppendFormat(" and username = '{0}'", txt_username.Text.Trim());
            if (txtStartDt.SelectedDate != DateTime.MinValue && txtEndDt.SelectedDate != DateTime.MinValue)
                where.AppendFormat(" and DATEDIFF(DAY,createDt,'{0}')<=0 AND DATEDIFF(DAY,createDt,'{1}')>=0", txtStartDt.SelectedDate, txtEndDt.SelectedDate);

            DataSet ds = logic.passwordHistory.select(where.ToString(), "createDt DESC", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            rpt_list.DataSource = ds.Tables[1];
            rpt_list.DataBind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            rptBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }
    }
}
